{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>分类列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">

                <!--搜索框结束-->
                <div class="hr-line-dashed"></div>
                <div class="example-wrap">
                    <div class="example">
                        <table class="table table-bordered table-hover">
                            <thead>
                                <tr class="long-tr">
                                    <th>ID</th>
                                    <th>标题</th>
                                    <th>商品地址</th>
                                    <th>分类名称</th>
                                    <th>券后价</th>
                                    <th>开售时间</th>
                                    <th>下架时间</th>
                                    <th>优惠券数量</th>
                                    <th>优惠券链接</th>
                                    <th>状态</th>
                                    <th>佣金</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="list-content">
                            {volist name="data.lists" id="vo"}
                                <tr class="long-td">
                                    <td>{$vo.id}</td>
                                    <td>{$vo.title}</td>
                                    <td><a href="{$vo.web_address}" target="_blank">点击查看</a></td>
                                    <td>{$vo.goods_cate.name}</td>
                                    <td>{$vo.last_price}</td>
                                    <td>{$vo.sale_time|date="Y-m-d H:i",###}</td>
                                    <td>{$vo.end_time|date="Y-m-d H:i",###}</td>
                                    <td>{$vo.coupon_nums}</td>
                                    <td><a href="{$vo.coupon_address}" target="_blank">点击查看</a></td>
                                    <td>
                                    {switch name="vo.status"}
                                        {case value="1"}
                                            <a class="red" href="javascript:;">
                                                <div id="zt{$vo.id}"><span class="label label-info">待审核</span></div>
                                            </a>
                                        {/case}
                                        {case value="2"}
                                        {if condition="$vo.end_time > time()"}
                                            <a class="red" href="javascript:;">
                                                <div id="zt{$vo.id}"><span class="label label-danger">通过</span></div>
                                            </a>
                                        {else /}
                                            <a class="red" href="javascript:;">
                                                <div id="zt{$vo.id}"><span class="label label-info">下架</span></div>
                                            </a>
                                        {/if}
                                        {/case}
                                        {case value="3"}
                                            <a class="red" href="javascript:;">
                                                <div id="zt{$vo.id}"><span class="label label-danger">拒绝</span></div>
                                            </a>
                                        {/case}
                                        {default /}
                                            <a class="red" href="javascript:;">
                                                <div id="zt{$vo.id}"><span class="label label-info">下架</span></div>
                                            </a>
                                    {/switch}
                                    </td>
                                    <td>{$vo.commision*$vo.last_price/100}</td>
                                    <td>
                                    {eq name="vo.status" value="1"}
                                        <a href="javascript:;" onclick="examine({$vo.id},2)" class="btn btn-primary btn-xs"><i class="fa fa-paste"></i> 通过</a>&nbsp;&nbsp;
                                        <a href="javascript:;" onclick="refuse({$vo.id})" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> 拒绝</a>
                                    {/eq}
                                    </td>
                                </tr>
                            {/volist}
                            </tbody>
                        </table>
                        {$data.page}
                    </div>
                </div>
                <!-- End Example Pagination -->
            </div>
        </div>
    </div>
<!-- End Panel Other -->
</div>

{include file="public/footer" /}

<script type="text/javascript">
    function examine(id,status){
        if(status == 2){
            var str = '您确定通过该请求吗？';
        }else{
            var str = '您确定拒绝该请求吗？';
        }
        var index = layer.confirm(str, {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('{:url("Goods/examine")}',{'id':id,'status':status},function(data){
              console.log(data);
                layer.close(index);
                if(data.code == 1){
                    layer.msg(data.msg, {
                        icon: 1,time:1000
                    },function(){
                        window.location.reload()
                    });
                }else{
                    layer.msg(data.msg, {
                        icon: 2,time:1000
                    });
                }

            },'json');
        }, function(){
            layer.close(index);
        });
    }

    //拒绝
    function refuse(id){
        layer.prompt({title: '输入不通过的原因，并确认', formType: 2,area: ['300px', '200px']}, function(text, index){
            $.post('{:url("Goods/refuse")}',{'id':id,'content':text},function(data){
                if(data.code == 1){
                    layer.msg(data.msg, {
                        icon: 1,time:1000
                    },function(){
                        window.location.reload()
                    });
                }else{
                    layer.msg(data.msg, {
                        icon: 2,time:1000
                    });
                }
            },'json');
        });
    }
</script>
</body>
</html>
